package com.fxd.crm.web.controller.grade;

import com.fxd.crm.model.CourseOrder;
import com.fxd.crm.model.curdResult;
import com.fxd.crm.model.grade;
import com.fxd.crm.service.ICourseOrderService;
import com.fxd.crm.service.IGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;

/**
 * @auther fuxudong
 * @date 2021/4/3 - 14:04
 */
@Controller
@RequestMapping("/grade")
public class gradeController {

    @Autowired
    IGradeService gradeService;

    @RequestMapping("list")
    public String list() {
        return "grade/list";
    }

    @RequestMapping("stulist")
    public String stulist() {
        return "studentgrade/list";
    }


    @RequestMapping("add")
    public String add() {
        return "grade/add";
    }

    @RequestMapping("edit")
    public String edit(Model model ,String gradeType,String name) {
        HashMap<String, String> map = new HashMap<>();
        map.put("gradeType",gradeType);
        map.put("name",name);
        grade grade = gradeService.findByOrderId(map);
        model.addAttribute("grade", grade);
        return "grade/edit";
    }

    @RequestMapping("delete")
    public curdResult delete(grade grade) {
        curdResult curdResult = new curdResult();
        gradeService.deleteByOrderId(grade);
        return curdResult;

    }






}
